import 'package:lx_widgets_library/extension/enum_ex.dart';

import 'package:lx_widgets_library/language/language_util.dart';

// 报修类型
enum ReportType {
  other(0, ''),
  exterior(1, ''),
  noise(2, ''),
  motor(3, ''),
  battery(4, ''),
  app(5, ''),
  firmware(6, '');

  final int rawValue;
  final String name;
  const ReportType(this.rawValue, this.name);
  // 通过 title 获取枚举类型
  static ReportType? getTypeByTitle(String title) =>
      ReportType.values.firstWhereOrNull((activity) => activity.name == title);
  // 通过 rawValue 获取枚举类型
  static ReportType? getTypeByNum(int rawValue) => ReportType.values
      .firstWhereOrNull((activity) => activity.rawValue == rawValue);

  String get title {
    switch (this) {
      case ReportType.exterior:
        return AppLanguageUtil.to.titleExterior;
      case ReportType.noise:
        return AppLanguageUtil.to.titleNoise;
      case ReportType.motor:
        return AppLanguageUtil.to.titleMotor;
      case ReportType.battery:
        return AppLanguageUtil.to.titleBattery;
      case ReportType.app:
        return AppLanguageUtil.to.titleApp;
      case ReportType.firmware:
        return AppLanguageUtil.to.titleFirmware;
      case ReportType.other:
        return AppLanguageUtil.to.titleOther;
    }
  }
}
